<?php


namespace app\common\service;

// 处理业务

use app\common\model\Admin;
use app\common\model\Order;
use app\common\model\OrderExpress;
use app\common\model\ServiceMiddle;
use app\common\model\Vcode;
use plug\SHttp;
use plug\SUtil;
use plug\SConstant;


class ServiceApi extends ServiceBase
{

    // h5 统计数量
    public function GetCountOrder($userId)
    {
        // 商品订单统计
        $status = ['1','3','4','10'];
        $data = [];
        foreach ($status as $val){
            $where = [
                'user_id' => $userId,
                'order_status'  => $val,
                'is_comment'    => 0,
                'is_show'   => 1,
                'order_type' => [1,2],
            ];
            if($val != 4){
                unset($where['is_comment']);
            }
            $rs = Order::where($where)->count();
            $data[] = $rs;
        }

        // 服务订单统计
        $servie_status = ["1,2","3"];
        $service = [];
        foreach ($servie_status as $val){
            $where = [
                ['user_id', '=', $userId],
                ['state', 'in', $val],
                ['pay_state', '=', 2],
                ['is_show', '=', 1],
            ];
            $rs = ServiceMiddle::where($where)->count();
            $service[] = $rs;
        }

        $tva = [
            'order' => $data,
            'service' => $service
        ];
        return $tva;
    }


}